/**
 * 
 */
package com.myworld.config.mq.rocket.producer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName: RocketMQProductorConfiguration
 * @Description: RocketMQ 生产者bean 配置
 * @author zhuqiang
 * @date 2018年12月29日 上午11:23:36
 */
@Configuration
public class RocketMQProductorConfiguration {
	public static final Logger loggger = LoggerFactory.getLogger(RocketMQProductorConfiguration.class);
	/**
	 * rocketMq名称服务器地址，以分号分割
	 */
	@Value("${rocketMq.namesrvAddr}")
	private String namesrvAddr;
	/**
	 * rocketMq生产者组名称
	 */
	@Value("${rocketMq.producerGroup}")
	private String producerGroup;

	/**
	 * mq生产者bean
	 * 
	 * @return
	 * @throws Exception
	 */
	@Bean(name = "jfMqMQProducer", initMethod = "start", destroyMethod = "shutdown")
	public DefaultMQProducer getJFMqMQProducer() throws Exception {
		DefaultMQProducer producer = new DefaultMQProducer();
		producer.setNamesrvAddr(namesrvAddr);// rocketMq名称服务器地址，以分号分割
		producer.setProducerGroup(producerGroup);// 生产者组
		producer.setVipChannelEnabled(false); //关闭VIP通道
		loggger.info("###初始化JfMqMQProducer, namesrvAddr:{}, producerGroup:{}", namesrvAddr, producerGroup);
		return producer;
	}

}
